# -*- coding: utf-8 -*-
from src.game.entity.living import EntityLiving
from src.game.talent.archer import ArcherTalent
import pygame


class EntityMob(EntityLiving):
    
    speed = 0.025    
    name = "entitymob"
    
    def __init__(self, talent):
        EntityLiving.__init__(self, 20, talent)
        self.collision = True
        self.hasAI = True
        self.width = 0.5
        self.height = 0.5
        self.view = 0.0
        self.sprite = pygame.Surface((32, 32))
        
        
        
    def render(self, client, viewport):
        EntityLiving.render(self, client, viewport)
        localX, localY = viewport.globalToLocale(self.x, self.y)
        
        # rotate around center
        loc = self.sprite.get_rect().center
        self.sprite = pygame.transform.rotate(self.sprite, self.view)
        self.sprite.get_rect().center = loc

        client.window.surface.blit(self.sprite, (localX * 64, localY * 64))
        
    def readFromPSO(self, pso):
        EntityLiving.readFromPSO(self, pso)
        self.view = pso.get("view")

    def writeToPSO(self, pso):
        EntityLiving.writeToPSO(self, pso)
        pso.set("view", self.view)